﻿@model LogOnViewModel
@{
    var returnUrl = ViewData.ContainsKey(GalleryConstants.ReturnUrlViewDataKey) ? (string)ViewData[GalleryConstants.ReturnUrlViewDataKey] : Request.RawUrl;
}
@using (Html.BeginForm("Register", "Authentication"))
{
    @Html.AntiForgeryToken()
    @Html.Hidden("ReturnUrl", returnUrl)
    @Html.Hidden("LinkingAccount", Model.External != null)

    if (Model.External != null)
    {
        @Html.HiddenFor(m => m.External.ProviderAccountNoun)
        @Html.HiddenFor(m => m.External.AccountName)
    }

    <div class="form-group @Html.HasErrorFor(m => m.Register)">
        @Html.ShowValidationMessagesFor(m => m.Register)
    </div>

    <div class="form-group @Html.HasErrorFor(m => m.Register.Username)">
        @Html.ShowLabelFor(m => m.Register.Username, isrequired: true)
        @Html.ShowTextBoxFor(m => m.Register.Username, "input-brand")
        @Html.ShowValidationMessagesFor(m => m.Register.Username)
    </div>
    if (Model.External == null)
    {
        <div class="form-group @Html.HasErrorFor(m => m.Register.Password)">
            @Html.ShowLabelFor(m => m.Register.Password)
            @Html.ShowPasswordFor(m => m.Register.Password, "input-brand")
            @Html.ShowValidationMessagesFor(m => m.Register.Password)
        </div>
    }
    <div class="form-group @Html.HasErrorFor(m => m.Register.EmailAddress)">
        @Html.ShowLabelFor(m => m.Register.EmailAddress)
        @if (Model.External != null && !string.IsNullOrEmpty(Model.Register.EmailAddress))
        {
            @Html.HiddenFor(m => m.Register.EmailAddress)
            <p>@Model.Register.EmailAddress</p>
        }
        else
        {
            @Html.ShowEmailBoxFor(m => m.Register.EmailAddress, "input-brand")
        }
        @Html.ShowValidationMessagesFor(m => m.Register.EmailAddress)
    </div>
    <div class="panel panel-default text-center">
        <div class="panel-body">
            By clicking Register you agree that you have read and accept our
            <a href="@Url.Terms()">Terms of Use</a> and <a href="@Url.Privacy()">Privacy Statement</a>.
        </div>
    </div>
    <div class="form-group">
        <input type="submit" class="btn btn-brand form-control" value="Register" />
    </div>
}
